home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / WorldScript.h < prev   
Encoding:
C/C++ Source or Header  |  1994-07-17  |  9.8 KB  |  358 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __WORLDSCRIPT__
  18. #define __WORLDSCRIPT__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __TRAPS__
  27. #include <Traps.h>
  28. #endif
  29.  
  30. #ifndef __QUICKDRAWTEXT__
  31. #include <QuickdrawText.h>
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if GENERATINGPOWERPC
  39. #pragma options align=mac68k
  40. #endif
  41.  
  42. #ifdef __CFM68K__
  43. #pragma lib_export on
  44. #endif
  45.  
  46.  
  47. enum {
  48.     kVariableLengthArray        = 1
  49. };
  50.  
  51. typedef UInt16 WSIOffset;
  52.  
  53. typedef UInt8 WSIByteCount;
  54.  
  55. typedef UInt8 WSIByteIndex;
  56.  
  57. /* offset from start of sub-table to row in state table */
  58. typedef UInt16 WSIStateOffset;
  59.  
  60. typedef UInt32 WSITableOffset;
  61.  
  62. typedef UInt16 WSISubtableOffset;
  63.  
  64. typedef UInt16 WSIGlyphcode;
  65.  
  66. typedef UInt32 WSITableIdentifiers;
  67.  
  68.  
  69. enum {
  70.     kScriptSettingsTag            = 'info',
  71.     kMetamorphosisTag            = 'mort',
  72.     kGlyphExpansionTag            = 'g2g#',
  73.     kPropertiesTag                = 'prop',
  74.     kJustificationTag            = 'kash',
  75.     kCharToGlyphTag                = 'cmap',
  76.     kGlyphToCharTag                = 'pamc',
  77.     kFindScriptRunTag            = 'fstb'
  78. };
  79.  
  80. /****             L O O K U P    T A B L E    T Y P E S        ****/
  81. enum {
  82.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  83.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  84.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  85.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  86.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  87. };
  88.  
  89. typedef unsigned short WSILookupTableFormat;
  90.  
  91. typedef unsigned short WSILookupValue;
  92.  
  93. /* An offset from the beginning of the lookup table */
  94. typedef unsigned short WSILookupOffset;
  95.  
  96. /*    FORMAT SPECIFIC DEFINITIONS */
  97. /*
  98.         lookupSimpleArray:
  99.         
  100.         This is a simple array which maps all glyphs in the font
  101.         to lookup values.
  102.     */
  103. struct WSILookupArrayHeader {
  104.     WSILookupValue                    lookupValues[1];            /* The array of values indexed by glyph code */
  105. };
  106. typedef struct WSILookupArrayHeader WSILookupArrayHeader;
  107.  
  108. /*
  109.         lookupTrimmedArray:
  110.         
  111.         This is a single trimmed array which maps a single range
  112.         of glyhs in the font to lookup values.
  113.     */
  114. struct WSILookupTrimmedArrayHeader {
  115.     WSIGlyphcode                    firstGlyph;
  116.     WSIGlyphcode                    limitGlyph;
  117.     WSILookupValue                    valueArray[1];
  118. };
  119. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  120.  
  121. /* The format specific part of the subtable header */
  122. union WSILookupFormatSpecificHeader {
  123.     WSILookupArrayHeader            lookupArray;
  124.     WSILookupTrimmedArrayHeader        trimmedArray;
  125. };
  126. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  127.  
  128. /* The overall subtable header */
  129. struct WSILookupTableHeader {
  130.     WSILookupTableFormat            format;                        /* table format */
  131.     WSILookupFormatSpecificHeader    fsHeader;                    /* format specific header */
  132. };
  133. typedef struct WSILookupTableHeader WSILookupTableHeader;
  134.  
  135. /****        G L Y P H    E X P A N S I O N    ****/
  136.  
  137. enum {
  138. /* fixed 1.0 */
  139.     kCurrentGlyphExpansionVersion = 0x00010000
  140. };
  141.  
  142. typedef unsigned short GlyphExpansionFormats;
  143.  
  144.  
  145. enum {
  146.     GlyphExpansionLookupFormat    = 1,
  147.     GlyphExpansionContextualFormat = 2
  148. };
  149.  
  150. struct ExpandedGlyphCluster {
  151.     WSIByteCount                    numGlyphs;
  152.     WSIByteIndex                    bestGlyph;
  153.     WSIGlyphcode                    glyphs[1];
  154. };
  155. typedef struct ExpandedGlyphCluster ExpandedGlyphCluster;
  156.  
  157. struct ExpandedGlyphOffset {
  158.     WSIGlyphcode                    glyph;
  159.     WSIOffset                        offset;                        /* offset to ExpandedGlyphCluster */
  160. };
  161. typedef struct ExpandedGlyphOffset ExpandedGlyphOffset;
  162.  
  163. struct GlyphExpansionTable {
  164.     Fixed                            version;
  165.     short                            format;
  166.     short                            expansionNumer;
  167.     short                            expansionDenom;                /* num/denom ratio for expansion <2> */
  168.         union {
  169.                 struct GlyphExpansionStateTable {
  170.                     WSISubtableOffset                stateTableOffset;
  171.                     WSISubtableOffset                classTableOffset;
  172.                     WSISubtableOffset                actionTableOffset; /* state, class and actions tables follow here... */
  173.                 }                            stateTable;
  174.             WSILookupTableHeader            lookup;                /* expanded glyph clusters follow here... */
  175.         }                            table;
  176. };
  177. typedef struct GlyphExpansionTable GlyphExpansionTable;
  178.  
  179. /* Glyph-to-Character constants and types  */
  180.  
  181. enum {
  182.     kCurrentGlyphToCharVersion    = (Fixed)0x00010100
  183. };
  184.  
  185. typedef unsigned short GlyphToCharLookupFormats;
  186.  
  187.  
  188. enum {
  189.     kGlyphToCharLookup8Format    = 1,
  190.     kGlyphToCharLookup16Format    = 2,
  191.     kGlyphToCharLookup32Format    = 3
  192. };
  193.  
  194. typedef UInt8 GlyphToCharFontIndex;
  195.  
  196. typedef UInt8 QDGlyphcode;
  197.  
  198. struct GlyphToCharActionTable {
  199.     WSISubtableOffset                fontNameOffset;                /* offset relative to this table */
  200.     WSILookupTableHeader            actions;                    /* only support lookupSimpleArray format for now */
  201. };
  202. typedef struct GlyphToCharActionTable GlyphToCharActionTable;
  203.  
  204. struct GlyphToCharActionHeader {
  205.     short                            numTables;                    /* 0..n */
  206.     WSISubtableOffset                offsets[1];                    /* offsets from start of action table header */
  207. };
  208. typedef struct GlyphToCharActionHeader GlyphToCharActionHeader;
  209.  
  210. struct GlyphToCharHeader {
  211.     Fixed                            version;
  212.     WSISubtableOffset                actionOffset;                /* offset to GlyphToCharActionHeader */
  213.     short                            format;                        /* size of font mask */
  214.     WSILookupTableHeader            mappingTable;
  215. };
  216. typedef struct GlyphToCharHeader GlyphToCharHeader;
  217.  
  218. /* JUSTIFICATION TYPES
  219.     WorldScript supports justification of text using insertion. The justification
  220.     table specifies a insertion string to insert between 2 specified glyphs.
  221.     Each combination of inter-glyph boundary can be assigned a justification priority,
  222.     the higher the priority the more justification strings inserted at that position.
  223.     
  224.     The priorities for each inter-glyph boundary are specified by the justification table's
  225.     state table.
  226.     
  227.     Special handling is done for scripts which use spaces to justify, because the width of 
  228.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  229.     per inserting string is specified in the justification table.
  230.  
  231. */
  232.  
  233. enum {
  234. /* 1.0 not supported */
  235.     kCurrentJustificationVersion = 0x0200
  236. };
  237.  
  238. enum {
  239.     kJustificationStateTableFormat = 1
  240. };
  241.  
  242. enum {
  243. /* WSI's internal limitation <12> */
  244.     kMaxJustificationStringLength = 13
  245. };
  246.  
  247. typedef UInt8 WSIJustificationPriority;
  248.  
  249.  
  250. enum {
  251.     WSIJustificationSetMarkMask    = 0x80
  252. };
  253.  
  254. struct WSIJustificationStateEntry {
  255.     WSIJustificationPriority        markPriority;                /* non-zero priorities means insertion */
  256.     WSIJustificationPriority        priority;
  257.     WSIStateOffset                    newState;
  258. };
  259. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  260.  
  261. typedef unsigned short WSIJustificationClasses;
  262.  
  263.  
  264. enum {
  265.     wsiJustEndOfLineClass        = 0,
  266.     wsiJustEndOfRunClass        = 1,
  267.     wsiJustDeletedGlyphClass    = 2,
  268.     wsiJustUserDefinedClass        = 3
  269. };
  270.  
  271. typedef unsigned short WSIJustificationStates;
  272.  
  273.  
  274. enum {
  275.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  276.     wsiStartOfRunState            = 1,
  277.     wsiUserDefinedState            = 2
  278. };
  279.  
  280. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  281. typedef UInt8 WSIJustificationClassOffset;
  282.  
  283. struct WSIJustificationStateTable {
  284.     short                            maxPriorities;
  285.     unsigned short                    rowWidth;                    /* width of a state table row in bytes */
  286.     short                            classTableOffset;
  287.     short                            stateTableOffset;
  288. };
  289. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  290.  
  291. struct WSIJustificationHeader {
  292.     short                            version;
  293.     short                            format;
  294.     Point                            scaling;                    /* numer/denom scaling of priority weights <7> */
  295.     unsigned short                    spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  296.     unsigned short                    justStringOffset;            /* offset to justification string */
  297.     WSIJustificationStateTable        stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  298. };
  299. typedef struct WSIJustificationHeader WSIJustificationHeader;
  300.  
  301. /* Line Layout's Property table version <11> */
  302.  
  303. enum {
  304. /* v1.0 */
  305.     currentPropsTableVersion    = 0x00010000
  306. };
  307.  
  308. enum {
  309. /* ??? is this right */
  310.     kCharToGlyphCurrentVersion    = 0100
  311. };
  312.  
  313. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  314. enum {
  315.     kScriptsDefaultJustWeight    = -1
  316. };
  317.  
  318. struct WSIGlyphInfoRec {
  319.     UInt8                            qdChar;
  320.     SInt8                            rightToLeft;                /* !0 means rightToLeft, 0 means leftToRight */
  321.     short                            fontID;
  322.     short                            originalOffset;                /* or negative original offset if not in original text input */
  323.     unsigned short                    unused;                        /* long-align */
  324. };
  325. typedef struct WSIGlyphInfoRec WSIGlyphInfoRec, **WSIGlyphInfoHandle;
  326.  
  327. typedef Handle WSILayoutHandle;
  328.  
  329. extern pascal WSILayoutHandle NewWSILayout(WSILayoutHandle layoutH, Ptr text, short txLength, short lineDirection, unsigned long flags, OSErr *err)
  330.  FOURWORDINLINE(0x2F3C, 0X8414, 0x0040, 0xA8B5);
  331. extern pascal WSILayoutHandle JustifyWSILayout(WSILayoutHandle layoutH, Fixed slop, short priorityWeight, JustStyleCode styleRunPosition, Point numer, Point denom, OSErr *err)
  332.  FOURWORDINLINE(0x2F3C, 0x8418, 0x0042, 0xA8B5);
  333. extern pascal Fixed MeasureWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  334.  FOURWORDINLINE(0x2F3C, 0x840C, 0x0044, 0xA8B5);
  335. extern pascal void DrawWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  336.  FOURWORDINLINE(0x2F3C, 0x800C, 0x0046, 0xA8B5);
  337. /* "low-level" routines */
  338. extern pascal WSIGlyphInfoHandle GetWSILayoutParts(WSILayoutHandle layoutH, WSIGlyphInfoHandle destH, short *numGlyphs, OSErr *err)
  339.  FOURWORDINLINE(0x2F3C, 0x8410, 0x0048, 0xA8B5);
  340. extern pascal void DrawWSIGlyphs(short length, Ptr qdCodes, Point numer, Point denom)
  341.  FOURWORDINLINE(0x2F3C, 0x800E, 0x004A, 0xA8B5);
  342. extern pascal Fixed xMeasureWSIGlyphs(Ptr *qdCodes, short length, Point numer, Point denom)
  343.  FOURWORDINLINE(0x2F3C, 0x840E, 0x004C, 0xA8B5);
  344.  
  345. #ifdef __CFM68K__
  346. #pragma lib_export off
  347. #endif
  348.  
  349. #if GENERATINGPOWERPC
  350. #pragma options align=reset
  351. #endif
  352.  
  353. #ifdef __cplusplus
  354. }
  355. #endif
  356.  
  357. #endif /* __WORLDSCRIPT__ */
  358.